package com.renjith.util.dtd;
import java.io.*; 
import java.net.*; 
import java.util.HashMap;
import java.util.Map;
public class Test { 
	private static int startIndex = 0; 
	private static Map map = new HashMap();
	public static void main(String[] args) throws Exception { 
		URL yahoo = new URL("http://java.sun.com/dtd/web-app_2_3.dtd"); 
		URLConnection yc = yahoo.openConnection(); 
		BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); 
		String inputLine;
		String dtd = "";
		while ((inputLine = in.readLine()) != null){
			dtd+=inputLine;
			
		}
		printTokens(dtd);
		System.out.println("===============");
		
	}
	private static void printTokens(String dtd) {
		String token = "";
		//System.out.println("DTD"+dtd);
		token = dtd.substring(0,dtd.indexOf(">",dtd.indexOf("<!ELEMENT"))+1);
		System.out.println("token"+token);
		startIndex = dtd.indexOf(">", dtd.indexOf("<!ELEMENT"))+1;
		System.out.println(startIndex);
		if(startIndex !=0){
			printTokens(dtd.substring(startIndex));
		}
		
	
	}
}
																																																																																																																																							// s.indexOf(">")-1));
																																																																																																																																							// } }
																																																																																																																																							// System.out.println("\n"
																																																																																																																																							// +
																																																																																																																																							// counter
																																																																																																																																							// + "
																																																																																																																																							// links
																																																																																																																																							// found
																																																																																																																																							// on
																																																																																																																																							// this
																																																																																																																																							// page");
																																																																																																																																							// in.close();
																																																																																																																																							// } }
